import map from './Map/index.vue'

export default {
  name: 'Dingdan',
  data () {
    return {
      dialogTableVisible: false,
      dingdanInfo: [],
      dingdanList: {
        query: '',
        pagenum: 1,
        pagesize: 5
      },
      total: 0
    }
  },
  created () {
    this.getDingdanList()
  },
  components: {
    'text-map': map
  },
  methods: {
    async getDingdanList () {
      const { data } = await this.$get('orders', { params: this.dingdanList })
      this.total = data.total
      this.dingdanInfo = data.goods
    },
    sizeChangeHandler (val) {
      this.dingdanList.pagesize = val
      this.getDingdanList()
    },
    currentChangeHandler (val) {
      this.dingdanList.pagenum = val
      this.getDingdanList()
    }
  },
  filters: {
    format (val) {
      if (val === '0') {
        return '未付款'
      } else return '已付款'
    },
    getTimes (val) {
      const t = new Date(val)
      const year = t.getFullYear()
      const month = t.getMonth() + 1
      const date = t.getDate()
      const hour = t.getHours()
      const minutes = t.getMinutes()
      const seconds = t.getSeconds()
      return `${year} 年 ${month} 月 ${date} 日 ${hour} 时 ${minutes} 分 ${seconds} 秒`
    }
  }
}
